<?php 
    include_once "backend/classes/User.php";
    session_start();
    include_once "backend/session.php";
    if (!isLoggedIn()) {exit();}
    if ($_SESSION['User']->UserType != "Representative" && $_SESSION['User']->UserType != 'Manager') {exit();}
    include_once "backend/db/db_cse305.php";
?>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title> Mailing List </title>
        <link rel="stylesheet" type="text/css" href="css/style.css">
        <link rel="stylesheet" type="text/css" href="css/main.css">
        <script src="js/sortable.js"></script>
    </head>
    <body>
        <table id="stock_list_table" class="rounded-corner sortable">
            <thead style="text-align:center;"><tr>
                <th>Customer Name</th><th>Email</th>
            </tr></thead>
            <tbody id="stock_list_table_body">
                <?php
                    $query = "SELECT FirstName, LastName, EmailAddress FROM users JOIN customer USING (UserID)";
                    $result = mysql_query($query) or die(mysql_error());
                    while ($row = mysql_fetch_array($result)) {
                        echo "<tr><td>" . $row["FirstName"] . " " . $row["LastName"] . "</td>";
                        echo "<td>" . $row["EmailAddress"] . "</td>";
                    }
                ?>
            </tbody>
        </table>
    </body>
</html>
